Useful Links - ICM42688 Setup

From RidgeRun Developer Wiki

Follow Us On Twitter LinkedIn Email Share this page








This wiki page contains information on how to set up the SRX-IMU00-DEV device from SYSROX for NVIDIA Jetson platforms, specifically tested on the Jetson Orin Nano board running JetPack 6.2 (L4T 36.4.3). The steps are applicable to other platforms with a Linux kernel greater than 5.15.

These instructions target the SPI variant of the ICM42688.

Kernel Customization

First, enable the Linux kernel driver that supports the InvenSense ICM-426xx motion tracking devices over SPI, since the NVIDIA Jetson devices do not enable it by default.

Prepare the necessary directories

First, install the NVIDIA board support package by downloading the Driver Package (BSP) and Sample Root Filesystem from the drivers section on the following link. Extract the downloaded files with the following commands inside a work directory.

mkdir nvidia-jetson

tar xf Jetson_Linux_R36.4.3_aarch64.tbz2 -C nvidia-jetson/
sudo tar xpf Tegra_Linux_Sample-Root-Filesystem_R36.4.3_aarch64.tbz2 -C \
nvidia-jetson/Linux_for_Tegra/rootfs

Now run the following scripts inside the Linux_for_Tegra directory:

cd nvidia-jetson/Linux_for_Tegra

sudo ./tools/l4t_flash_prerequisites.sh

sudo ./apply_binaries.sh

(Optional step) Create a default user:

 sudo ./tools/l4t_create_default_user.sh -u <user_name> -p <password>

Obtaining the kernel sources

To obtain the kernel sources, run the following commands:

cd <install-path>/Linux_for_Tegra/source
./source_sync.sh -k -t jetson_36.4.3

Obtaining the Jetson-Linux toolchain

Then, it is required to download the Jetson-Linux toolchain from the Jetson release page located here. Execute the following commands to download and extract the toolchain:

mkdir $HOME/jetson-toolchain
cd $HOME/jetson-toolchain
wget https://developer.nvidia.com/downloads/embedded/l4t/r36_release_v3.0/toolchain/aarch64--glibc--stable-2022.08-1.tar.bz2
tar xf aarch64--glibc--stable-2022.08-1.tar.bz2

Applying the patches

Before building the kernel, enable support for the InvenSense ICM-426xx SPI driver by applying a patch to the kernel sources, as the support for the sensor ICM-42688-P was added in kernel version 6.10, as shown on this page.

The first thing is to apply this patch to the kernel sources located in the <install path>/Linux_for_Tegra/source/kernel/kernel-jammy-src directory. Next, add the following line at the end of the default kernel configuration file located in the path <install path>/Linux_for_Tegra/source/kernel/kernel-jammy-src/arch/arm64/configs/defconfig using a text editor of your choice:

CONFIG_INV_ICM42600_SPI=m

to load it as a module or use

CONFIG_INV_ICM42600_SPI=y

to make it built-in.

After that, you need to modify the device-tree of your board, in this case, for the Jetson Orin Nano the device-tree is called tegra234-p3768-0000+p3767-0005-nv.dts and it is located in the folder <install path>/Linux_for_Tegra/source/hardware/nvidia/t23x/nv-public. For this step, create a file in that folder called tegra234-p3768-0000-a0.dtsi. For example, and include the following content in that file:

#include <dt-bindings/gpio/tegra234-gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
/ {
	bus@0 {
		spi@3210000 {
			/delete-node/ spi@0;
			icm42688@0 {
				compatible = "invensense,icm42688";
				status = "okay";
				reg = <0x0>;
				spi-max-frequency = <12000000>;
				spi-cpha;
				spi-cpol;
				interrupt-parent = <&gpio>;
				interrupts = <TEGRA234_MAIN_GPIO(I, 6) IRQ_TYPE_EDGE_FALLING>;
				interrupt-names = "INT1";
				controller-data {
					nvidia,enable-hw-based-cs;
					nvidia,rx-clk-tap-delay = <0x10>;
					nvidia,tx-clk-tap-delay = <0x0>;
				};
			};
		};
	};
};

The next step is to include the file we created above in the main file i.e. tegra234-p3768-0000+p3767-0005-nv.dts, like this:

// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.

/dts-v1/;

#include "tegra234-p3768-0000+p3767-0005.dts"
#include "tegra234-p3768-0000+p3767-xxxx-nv-common.dtsi"
#include "tegra234-p3768-0000-a0.dtsi"

/ {
	bus@0 {
		host1x@13e00000 {
			nvdla0@15880000 {
				status = "disabled";
			};

			nvdla1@158c0000 {
				status = "disabled";
			};

			pva0@16000000 {
				status = "disabled";
			};
		};
	};
};

Building the Linux kernel

Then, run the following commands to build the Jetson Linux kernel and its in-tree modules:

cd <install-path>/Linux_for_Tegra/source
export CROSS_COMPILE=$HOME/jetson-toolchain/aarch64--glibc--stable-2022.08-1/bin/aarch64-buildroot-linux-gnu-
make -C kernel

Now, to install the kernel image and its in-tree modules execute the following commands:

export INSTALL_MOD_PATH=<install-path>/Linux_for_Tegra/rootfs/
sudo -E make install -C kernel
cp kernel/kernel-jammy-src/arch/arm64/boot/Image <install-path>/Linux_for_Tegra/kernel/Image

Building the DTBs

To build the DTBs go to the kernel sources directory and run the following commands:

cd <install-path>/Linux_for_Tegra/source
export CROSS_COMPILE=$HOME/jetson-toolchain/aarch64--glibc--stable-2022.08-1/bin/aarch64-buildroot-linux-gnu-
export KERNEL_HEADERS=$PWD/kernel/kernel-jammy-src
make dtbs

Execute the following command to install the dtbs:

cp kernel-devicetree/generic-dts/dtbs/* <install-path>/Linux_for_Tegra/kernel/dtb/

Flashing the device

To flash the board, follow this guide, depending on the device you are using. If it is a Jetson Orin Nano with an SD Card, put the board in forced recovery mode and execute the following command:

sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device mmcblk0p1 \
-c tools/kernel_flash/flash_l4t_external.xml -p "-c bootloader/generic/cfg/flash_t234_qspi.xml" \
--showlogs --network usb0 jetson-orin-nano-devkit internal

Pinmux Configuration

Once the board has been flashed successfully, we need to map the SPI ports on the Jetson Orin Nano using Jetson IO:

  • 1. Use Jetson-IO to configure pins:
sudo /opt/nvidia/jetson-io/jetson-io.py
  • 2. Once inside select "Configure Jetson 40-pin Header"
  • 3. Choose "Configure header pins manually".
  • 4. Select "spi1" and save changes.
  • 5. Reboot the system to apply the changes.

Connecting the Hardware

The connection will be as follows (From SRX-IMU00-DEV to the Jetson 40-pin expansion header):

  • 1. 3V3 pin --> 3.3V (pin 1)
  • 2. GND pin --> GND (any of the following pins: 6, 9, 14, 20, 25, 30, 34 or 39)
  • 3. MOSI pin --> SPI0_MOSI (pin 19)
  • 4. MISO pin --> SPI0_MISO (pin 21)
  • 5. CLK pin --> SPI0_SCK (pin 23)
  • 6. CS pin --> SPI0_CS0* (pin 24)
  • 7. INT pin --> GPIO07 (pin 32)

You can refer to the Jetson Orin Nano Developer Kit Carrier Board Specification to learn more about the 40-pin expansion header connections.

How to load the driver

To load the driver, run the following commands on the board:

sudo modprobe inv-icm42600
sudo modprobe inv-icm42600-spi


Info
Use this only in case that the driver is compiled as a module


Verify it was properly loaded running the next command:

sudo dmesg | grep -i spi 

# Sample output:
[   63.776310] SPI driver inv-icm42600-spi has no spi_device_id for invensense,icm42600
[   63.776343] SPI driver inv-icm42600-spi has no spi_device_id for invensense,icm42602
[   63.776346] SPI driver inv-icm42600-spi has no spi_device_id for invensense,icm42605
[   63.776347] SPI driver inv-icm42600-spi has no spi_device_id for invensense,icm42622
[   63.776348] SPI driver inv-icm42600-spi has no spi_device_id for invensense,icm42688
[   63.776884] inv-icm42600-spi spi0.0: mounting matrix not found: using identity...
[   63.776965] inv-icm42600-spi spi0.0: supply vdd not found, using dummy regulator
[   63.777221] inv-icm42600-spi spi0.0: supply vddio not found, using dummy regulator

Permissions

To use the device, please check the permissions:

sudo chmod -R 777 /sys/bus/iio/devices/iio\:device*
sudo chmod 777 /dev/iio\:device*


Info
This should be done every boot


Check with the example

Please, use this example to test the connectivity.